// pagesMine/component/housing/housing.js
import ajax from '../../../utils/index'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    item: Object,
    rule: Number,
    type: String
  },

  /**
   * 组件的初始数据
   */
  data: {
    /**
     * 审核状态：0未审核；1审核通过；2未通过；-1已屏蔽
     */
    checkStatus: ['审核中', '审核通过', '未通过']
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 审核状态事件
     */
    auditEvent() {
      const { item } = this.data
      if (item.checkStatus != 2) return;
      wx.showModal({
        title: '提示',
        content: item.checkReason || '未知错误, 请与客服联系',
        showCancel: false
      })
    },
    houseEvent() {
      const { type, item } = this.data
      const url = type == 0 ? `/pagesMine/pages/houseApprove/houseApprove?detailId=${item.id}` : null
      url ? wx.navigateTo({ url }) : ''
    },
    publishEvent() {
      const { item, checkStatus, type } = this.data
      if (item.checkStatus != 1) return ajax.showToast(checkStatus[item.checkStatus - 0]);
      wx.navigateTo({ url: `/pagesMine/pages/housingResource/housingResource?houseId=${item.id}&type=${type}` })
    },
    deleteEvent() {
      this.triggerEvent('delete', this.data.item)
    }
  }
})
